*********************
** Table 1: Descriptive statistics and hypothesis tests for the three tasks
*********************
* Create Table
	mat T = J(2,10,.)
	matrix annotmat = J(2,10,0)
 
	foreach j of numlist 0 1 {
		ttest Game12_Giving_In = Game12_Giving_Out if shift == `j'
		local i = `j' + 1
		mat T[`i',1] = r(mu_1)
		mat T[`i',2] = r(sd_1)
		mat T[`i',3] = r(mu_2)
		mat T[`i',4] = r(sd_2)
		mat T[`i',5] = r(mu_1) - r(mu_2)
		mat T[`i',6] = r(se)*sqrt(r(N_2))
		mat annotmat[`i',5] = 0 + 1*(r(p_u) < 0.1) + 1*(r(p_u) < 0.05) + 1*(r(p_u) < 0.01)
		
		ttest Game3_Giving_Out = 2.5 if shift == `j'
		mat T[`i',7] = r(mu_1)
		mat T[`i',8] = r(sd_1)
		mat annotmat[`i',7] = 0 + 1*(r(p_l) < 0.1) + 1*(r(p_l) < 0.05) + 1*(r(p_l) < 0.01)
		local n`i' = `r(N_1)'
		
		ttest SharingGameDiscrimination = 0 if shift == `j'
		mat T[`i',9] = r(mu_1)
		mat T[`i',10] = r(sd_1)
		mat annotmat[`i',9] = 0 + 1*(r(p_u) < 0.1) + 1*(r(p_u) < 0.05) + 1*(r(p_u) < 0.01)
	}
	
	ttest Game12_Giving_In, by(shift)
	local pCol1 = round(`r(p)',0.01)
	
	ttest Game12_Giving_Out, by(shift)
	local pCol2 = round(`r(p)',0.01)
	
	ttest Game12_GivingInMinusGivingOut, by(shift)
	local pCol3a = round(r(mu_1) - r(mu_2),0.001)
	local pCol3b = round(`r(p)',0.01)
	local pCol3 `pCol3b'
	
	ttest Game3_Giving_Out, by(shift)
	local pCol4 = round(`r(p)',0.01)
	
	ttest SharingGameDiscrimination, by(shift)
	local pCol5 = round(`r(p)'*10,0.1)/10

	mat rownames T = "Morning Shift (Jordanians)" "Afternoon Shift (Syrians)"
	
	frmttable using "2_output\Table1.doc", statmat(T) substat(1) sdec(2, 2, 2, 2, 2, 2, 2, 2, 2, 2) colwidth(12 10 10 10 10 3 2) varlabels replace ///
	ctitle("", "Task 1 and 2 Giving to In-Group", "Task 1 and 2 Giving to Out-Group", "Task 1 and 2 Difference in Giving (In-Group - Out-Group)", "Task 3 Allocation to Out-Group", "Discrimination (Aggregate Measure)") ///
	addcols("N" \ "`n1'" \ "" \ "`n2'" \ "") ///
	addrows("p(Diff {&ne} 0)" , "`pCol1'" , "`pCol2'", "`pCol3'", "`pCol4'", "`pCol5'") ///
	note("Notes: Standard deviations in parentheses; * p < 0.1, ** p < 0.05, *** p < 0.01. Significance levels indicated by stars result from testing for discrimination against the out-group (i.e., one-sided t-tests testing whether column 3 > 0, column 4 < 2.5, and column 5 > 0, respectively)." "The aggregate discrimination measure adds the discrimination from Tasks 1 and 2 to that in Task 3, i.e., column 3 + (2.5 - ccolumn 4") ///
	annotate(annotmat) asymbol("*","**", "***") ///
	a4 basefont(fs10) ///
	title("Table 1: Descriptive statistics and hypothesis tests for the three tasks")

* Have a nice day!
